<div class="bs-callout bs-callout-info">
    <h4>Categories</h4>
    <p><a href="<?php echo base_url()?>admin/category/add">+ Add new category</a></p>
</div>
<div style="float: right; width: 20%">
    <select id="parent" class="form-control">
        <option value="0">All</option>
        <?php
            foreach($categories as $key=>$value){
        ?>
        <option value="<?php echo $value['id']?>" <?php if($value['id'] == $selected) echo 'selected';?> ><?php echo $value['categoryname']?></option>
        <?php
            }
        ?>
    </select>
</div>
<table class="table table-hover table-bordered">
    <thead>
        <tr>
            <th width="5%">#</th>
            <th width="35%">Category name</th>
            <th width="35%">Slug</th>
            <th width="10%">Order</th>
            <th width="15%">Actions</th>
        </tr>
    </thead>
    <tbody>
        <?php
        if(isset($data) && !empty($data)){
            foreach($data as $key=>$value){
        ?>
        <tr>
            <td><?php echo $value['id']; ?></td>
            <td><?php echo $value['categoryname']; ?></td>
            <td><?php echo $value['slug']; ?></td>
            <td><?php echo $value['number']; ?></td>
            <td>
                <a href="<?php echo base_url()?>admin/category/edit/<?php echo $value['id']; ?>">Edit</a>
                <a rel="<?php echo base_url()?>admin/category/delete/<?php echo $value['id']; ?>" href="#" class="confirmDelete">Delete</a>
            </td>
        </tr>
        <?php }} ?>
    </tbody>
</table>
<script>
$("#parent").change(function(){
    var sel = $(this);
    var value = sel.val();
    window.location = '<?php echo base_url()?>admin/category/index/' + value;
})
</script>